package com.tuling.order.controller;

import com.tuling.annotation.RepeatSubmit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @Type OrderController.java
 * @Desc
 * @Author wzw
 * @Date 2024/8/11 16:34
 * Qwe@123..
 */
@RestController
@RequestMapping("/reduce")
public class OrderController {
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @GetMapping("/reduceStock/{id}")
    @RepeatSubmit(limitType = RepeatSubmit.Type.TOKEN,lockTime = 10)
    public void reduce(@PathVariable("id") String id){
        System.out.println("========={}"+id);

        HashMap<String, String> objectHashMap = new HashMap<>();
        objectHashMap.put("aa","vv");
        ConcurrentHashMap<String, String> objectObjectHashMap = new ConcurrentHashMap<>();
        objectObjectHashMap.put("aa","vv");

        objectObjectHashMap.get("aa");



        String s = stringRedisTemplate.opsForValue().get("autonomyName");
        System.out.println("xxxxxx");
    }


    public static void main(String[] args) throws InterruptedException {
        String aa = "abcdefr";
        //从开始到最后
        String substring = aa.substring(aa.length() >>1);
        String substring1 = aa.substring(0,aa.length() >>1);

        System.out.println(substring+":"+substring1);

        TimeUnit.SECONDS.sleep(1);

    }

}
